import 'package:date_format/date_format.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:test01/okhttp_test/page/pages/okhttp_main.dart';


/*
* 底部提示框测试代码
*
* */
void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    ///禁止程序横屏
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp, //只能纵向
      DeviceOrientation.portraitDown, //只能纵向
    ]);

    return MaterialApp(
      home: SnackBarTest(),
    );
  }
}

class SnackBarTest extends StatefulWidget {
  const SnackBarTest({Key key}) : super(key: key);

  @override
  _SnackBarTestState createState() => _SnackBarTestState();
}

class _SnackBarTestState extends State<SnackBarTest> {
  @override
  Widget build(BuildContext context) {
    return Container(
        color: Colors.white,
        alignment: Alignment.center,
        child: GestureDetector(
          onTap: () {
            mm(context);
          },
          child: Text("点击",
              style: TextStyle(

                  ///设置为下划线
                  decoration: TextDecoration.none,
                  color: Colors.greenAccent)),
        ));
  }
}
///底部提示框
void mm(BuildContext context){
  showModalBottomSheet(
      context: context,
      isDismissible: true,
      isScrollControlled: false,

      ///下方提示框
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(15),
              topRight: Radius.circular(15))),
      builder: (BuildContext context) {
        return Container(
          alignment: Alignment.center,
          height: 90,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              GestureDetector(
                onTap: () {
                  ///关闭底部提示框
                  Navigator.pop(context);

                  ///举报提示框
                  showDialog(
                    context: context,
                    builder: (context) {
                      return Center(
                          child: Container(
                            alignment: Alignment.center,
                            width: 255,
                            height: 165,

                            ///设置圆角
                            decoration: BoxDecoration(
                              color: Colors.white,
                              //设置四周圆角 角度
                              borderRadius:
                              BorderRadius.all(Radius.circular(10.0)),
                            ),
                            child: Column(
                              // mainAxisSize: MainAxisSize.min,
                              children: <Widget>[
                                Container(
                                  margin: EdgeInsets.only(top: 20),
                                  child: Text("提交举报",
                                      style: TextStyle(
                                        ///设置为下划线
                                        decoration: TextDecoration.none,
                                        color: Colors.black,
                                        fontSize: 18,
                                      )),
                                ),
                                Container(
                                  margin:
                                  EdgeInsets.only(top: 8, bottom: 16),
                                  child: Text("确认举报该动态",
                                      style: TextStyle(
                                        ///设置为下划线
                                        decoration: TextDecoration.none,
                                        color:
                                        Colors.black.withOpacity(0.5),
                                        fontSize: 18,
                                      )),
                                ),
                                Spacer(),

                                ///举报按钮
                                Row(
                                  crossAxisAlignment:
                                  CrossAxisAlignment.center,
                                  children: <Widget>[
                                    GestureDetector(
                                      onTap: () {
                                        Navigator.pop(context);
                                      },
                                      child: Container(
                                        height: 50,
                                        width: 127.5,
                                        alignment: Alignment.center,

                                        ///自定义边框
                                        decoration: BoxDecoration(
                                            border: Border(
                                                top: BorderSide(
                                                    color: Colors.black
                                                        .withOpacity(0.2),
                                                    width: 1),
                                                right: BorderSide(
                                                    color: Colors.black
                                                        .withOpacity(0.2),
                                                    width: 0.5))),

                                        child: Text(
                                          "再想想",
                                          style: TextStyle(

                                            ///设置为下划线
                                              decoration:
                                              TextDecoration.none,
                                              color: Colors.black,
                                              fontSize: 18),
                                        ),
                                      ),
                                    ),
                                    GestureDetector(
                                      onTap: () {
                                        Fluttertoast.showToast(msg: "感谢您的反馈，我们会尽快处理",toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.BOTTOM,
                                            textColor: Colors.white,
                                            fontSize: 12.0
                                        );
                                        Navigator.pop(context);
                                      },
                                      child: Container(
                                        height: 50,
                                        width: 127.5,
                                        alignment: Alignment.center,
                                        decoration: BoxDecoration(
                                            border: Border(
                                                top: BorderSide(
                                                    color: Colors.black
                                                        .withOpacity(0.2),
                                                    width: 1),
                                                left: BorderSide(
                                                    color: Colors.black
                                                        .withOpacity(0.2),
                                                    width: 0.5))),
                                        child: Text(
                                          "必须举报",
                                          style: TextStyle(

                                            ///设置为下划线
                                              decoration:
                                              TextDecoration.none,
                                              color: Colors.red,
                                              fontSize: 18),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ],
                            ),
                          ));
                    },
                  );
                },
                child: Container(
                  child: Text(
                    "举报",
                    style: TextStyle(fontSize: 18),
                  ),
                ),
              ),
              Container(
                height: 20,
              ),
              GestureDetector(
                onTap: () {
                  ///关闭底部提示框
                  Navigator.pop(context);
                },
                child: Container(
                  child: Text(
                    "取消",
                    style: TextStyle(fontSize: 18),
                  ),
                ),
              )
            ],
          ),
        );
      }).then((value) => print("结束"));
}


